<template>
  <div>
    <Find page="find3"></Find>
    <van-list
      class="pd-10"
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
    >
      <li class="w100pc bg fcc mt-15" v-for="iten in list" :key="iten.id">
        <div class="w100pc">
          <img :src=" `https://img.villaday.com${iten.imageUrl}`">
        </div>
        <div class="w100pc">
          <span class="pd">{{iten.title}}</span>
        </div>
      </li>
    </van-list>
  </div>
</template>

<script>
import Find from "@/components/Find";
export default {
  data() {
    return {
      list: [],
      loading: false,
      pageNum: 1,
      pageSize: 6,
      totalPge: "",
      finished: false
    };
  },
  components: {
    Find
  },
  methods: {
    //上拉加载 分页
    onLoad() {
      setTimeout(() => {
        let url = "/discover/getList";
        let data = {
          pageNum: this.pageNum,
          pageSize: this.pageSize
        };
        this.$axios
          .post(url, data)
          .then(res => {
            // console.log(res, "res");
            this.totalPge = res.totalPge;
            res.list.forEach(lists => {
              this.list.push(lists);
            });
            if (res.list <= this.pageSize) {
              this.finished = true;
            }
          })
          .then(() => {
            this.pageNum++; //页数增替
            // console.log(this.list);
            // 加载状态结束
            this.loading = false;
          });
      }, 800);
    }
  }
};
</script>

<style lang="less" scoped>
@import "../../style/find.less";
</style>